package com.materialcalendarview;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.drawable.shapes.OvalShape;

/**
 *
 * 自定义原型
 */
public class CustomOvalShape extends OvalShape {
    private int radius;
    public CustomOvalShape(int radius) {
        this.radius = radius;
    }

    @Override
    public void draw(Canvas canvas, Paint paint) {
        RectF rect = rect();
        if(radius == -1){
            int widthCha = (int) (rect.right - rect.left);
            int heightCha = (int) (rect.bottom - rect.top);
            radius = widthCha < heightCha ? widthCha/2:heightCha/2;
        }
        canvas.drawCircle(rect.centerX(), rect.centerY(), radius,
                paint);
    }
}
